//
//  Scene_tableViewCellNearT.m
//  EggSteward
//
//  Created by 王道林 on 16/9/3.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "Scene_tableViewCellNearT.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"
#import "ActionCycleModel.h"
#import "BaseLabel.h"
@interface Scene_tableViewCellNearT ()
@property (nonatomic, strong) UIImageView *imageview;
@property (nonatomic, strong) BaseLabel *lableTitle;
@property (nonatomic, strong) BaseLabel *lableAddress;
@property (nonatomic, strong) BaseLabel *lableCreate_time;
@end

@implementation Scene_tableViewCellNearT

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}

- (void)createSubView
{
    _imageview = [[UIImageView alloc] init];
    _imageview.image = [UIImage imageNamed:@"1203"];
    [self.contentView addSubview:_imageview];
    
    _lableTitle = [[BaseLabel alloc] init];
    _lableTitle.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    [self.contentView addSubview:_lableTitle];
    
    _lableAddress = [[BaseLabel alloc] init];
    _lableAddress.textColor = [UIColor colorWithWhite:0.364 alpha:1.000];
    [self.contentView addSubview:_lableAddress];
    
    _lableCreate_time = [[BaseLabel alloc] init];
     _lableCreate_time.textColor = [UIColor colorWithWhite:0.364 alpha:1.000];
    _lableCreate_time.textAlignment = 2; 
    [self.contentView addSubview:_lableCreate_time];
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    [_imageview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top);
        make.left.mas_equalTo(self.contentView.mas_left);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).mas_offset(-80);
        make.right.mas_equalTo(self.contentView.mas_right);
    }];
    
    [_lableTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_imageview.mas_bottom).mas_offset(10);
        make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10);
        make.height.mas_equalTo(30);
        make.right.mas_equalTo(self.contentView.mas_right);
    }];
    
    [_lableAddress mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_lableTitle.mas_bottom).mas_offset(10);
        make.left.mas_equalTo(self.contentView.mas_left).mas_offset(10);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(self.contentView.mas_width).multipliedBy(0.3);
    }];

    [_lableCreate_time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_lableTitle.mas_bottom).mas_offset(10);
        make.right.mas_equalTo(self.contentView.mas_right).mas_offset(-10);
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(self.contentView.mas_width).multipliedBy(0.5);
    }];


    
}

- (void)setModel:(ActionCycleModel *)model
{
    _model = model;
    
    [_imageview sd_setImageWithURL:[NSURL URLWithString:_model.pic] placeholderImage:[UIImage imageNamed:@"1203"]];
    _lableTitle.text = _model.title;
    _lableAddress.text = _model.address;
    _lableCreate_time.text = _model.create_time;
}




@end
